#include <iostream>
#include <vector>
#include <string>

using namespace std;

int compress(vector<char>& chars) {
    char c = chars[0]; int start = 1, times = 1;
    for(int i = 1; i <= chars.size(); i++){
        if(i < chars.size() && c == chars[i]){
            times++;
        }else{
            if(times > 1){
                chars.erase(chars.begin()+start, chars.begin()+i);
                if(times > 9){
                    for(char t : to_string(times)){
                        chars.insert(chars.begin()+start++, t);
                    }
                }else{
                    chars.insert(chars.begin()+start++, times + '0');
                }
            }
            i = start++, c = i < chars.size() ? chars[i] : ' ', times = 1;
        }
    }
    return chars.size();
}

int main(){
    vector<char> chars = { 'a', 'a', 'b', 'b', 'c', 'c', 'c' };
    // vector<char> chars = { 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b' };
    cout << compress(chars) << endl;
    return 0;
}
